﻿using NFine.Data.Entity.WeixinManage;
using NFine.Repository.WeixinManage;
using NFine.Util;
using SharpRepository.Repository.Specifications;
using System;
using System.Collections.Generic;
using System.Text;

namespace NFine.Service.WeixinManage
{
    public class WxMpCommonService
    {
        protected readonly Rabbit.WeiXin.MP.Api.ICommonService CommonService;
        protected Rabbit.WeiXin.MP.Api.AccountModel AccountModel;

        public WxMpCommonService()
        {
            AccountModel = new Rabbit.WeiXin.MP.Api.AccountModel
            {
                AppId = OperatorProvider.Provider.GetOperator().WxAccountModel.AppId,
                AppSecret = OperatorProvider.Provider.GetOperator().WxAccountModel.AppSecret,
                GetAccessToken = GetAccessToken
            };
            CommonService = new Rabbit.WeiXin.MP.Api.CommonService(AccountModel);
        }
        protected string GetAccessToken()
        {
            return CommonService.GetAccessToken().AccessToken;
        }
    }
}
